import {CHANGE_TITLE , CHNAGE_CONTEXT,CHANGE_CLASSIFY,SUBMIT} from './type';
import {marked} from 'marked';
import axios from 'axios'
export default {
    [CHANGE_TITLE] : function(state,input){
         state.title = input
    },
    [CHNAGE_CONTEXT] : function(state,textarea){
        state.context = textarea
    },
    [CHANGE_CLASSIFY] : function(state,classify){
        state.classify = classify
    },
    [SUBMIT] : function(state){
        //1.转换md-》html
        //2.组装数据
        //3.发送
        var obj = {
            title : state.title,
            content : marked.parse(state.context),
            classify : state.classify
        }
        axios.post('http://localhost:3000/submitPage' , {...obj}).then((result)=>{
            console.log(result)
        }).catch((err)=>{
            console.log(err)
        })
    }
}